// pages/me/setting/setting.js
import Util from '../../../../utils/utils';
import User from '../../../../utils/user';
Page({
  initPage() {
    console.log('Page Load...')
  },
  onShow: function() {
    this.passwordBox = this.selectComponent('#passwordBox')
  },
  data: {
    tipText: '请输入四位数密码',
    // 用于页面样式的
    valueIsShow: false,
    // 记录临时的值，点击按钮后再保存到对应变量中
    currentValue: '',
    firstValue: '',
    secondValue: '',
  },
  // 调用组件中的方法
  toggleValue() {
    this.setData({
      valueIsShow: !this.data.valueIsShow
    })
    this.passwordBox.toggleValue()
  },
  inputChange(e) {
    let currentValue = e.detail ;
    this.setData({
      currentValue
    })
  },
  saveInputValue() {
    let value = this.data.currentValue
    if (value.length < 4) {
      return
    }
    if (this.data.firstValue === '') {
      this.setData({
        firstValue: value,
      });
      console.log(value);
      //验证
      Util.request({
        url:'s/dict/InsertInviter',
        data:{
          pwd:value,
          store_service_id:2
        },
        callback:function (result) {
          if(result.status === 'ok'){
            Util.msg('验证成功！');
          }else{
            Util.msg('验证失败！');
          }
        }
      });
    } else {
      this.setData({
        secondValue: value
      })
    }
  },
  checkPassword(){
    this.saveInputValue()
    console.log('验证密码...')
  }
})
